package lumis.portal.channel.serialization;

import lumis.portal.PortalException;
import lumis.portal.channel.ChannelConfig;
import lumis.portal.serialization.BaseSerializationContext;
import lumis.portal.serialization.SerializationMessageConfigNode;
import lumis.portal.serialization.DeserializationContext;
import lumis.portal.serialization.SerializationContext;
import lumis.portal.serialization.operation.IConfigDeleter;
import lumis.portal.serialization.operation.IConfigPersister;

/**
 * Manager Interface for Channel serialization
 *
 * @version $Revision: 12025 $ $Date: 2010-10-08 17:45:58 -0300 (Fri, 08 Oct 2010) $
 * @since 4.0.7
 */
public interface IChannelSerializationManager extends IConfigPersister, IConfigDeleter
{
	// DESERIALIZATION
	
	/**
	 * Deserialize a channel.
	 * @param deserializationContext
	 * @param channelSerializableConfig
	 * @param parentChannelSerializableConfig
	 * @return deserialized channelId
	 * @throws PortalException
	 */
	public String deserialize(DeserializationContext deserializationContext, ChannelSerializableConfig channelSerializableConfig, ChannelSerializableConfig parentChannelSerializableConfig) throws PortalException;

	/**
	 * Deserialize channel content.
	 * 
	 * For all service instances below the channel the content must be deserialized.
	 * 
	 * @param deserializationContext context for deserialization
	 * @param channelSerializableConfig channel for which content must be deserialized
	 * @param parentChannelSerializableConfig parent channel of the channel to be deserialized
	 * @throws PortalException
	 * @since 4.2.0
	 */
	public void deserializeContent(DeserializationContext deserializationContext, ChannelSerializableConfig channelSerializableConfig, ChannelSerializableConfig parentChannelSerializableConfig) throws PortalException;

	/**
	 * Deserialize a {@link ChannelConfig} object.
	 * @param deserializationContext
	 * @param channelId
	 * @return
	 */
	public ChannelConfig deserializeConfig(DeserializationContext deserializationContext, String channelId) throws PortalException;

	// SERIALIZATION
	
	/**
	 * Serialize a channel.
	 * @param serializationContext
	 * @param channelId
	 * @return
	 * @throws PortalException
	 */
	public ChannelSerializableConfig serialize(SerializationContext serializationContext, String channelId) throws PortalException;

	// GENERAL
	
	/**
	 * Set up a serialization context, defining settings such as class aliases, field aliases, transient fields, omitted collections etc.
	 * @param serializationContext
	 */
	public void setupSerializationContext(BaseSerializationContext serializationContext);

	/**
	 * Get a {@link SerializationMessageConfigNode} object containing fully recursive information about a channel.
	 * @param serializationContext
	 * @param channelConfig
	 * @return
	 * @throws PortalException
	 */
	public SerializationMessageConfigNode getSerializationMessageConfigNode(BaseSerializationContext serializationContext, ChannelConfig channelConfig) throws PortalException;
	
	/**
	 * Get the number of steps of a channel serialization process. 
	 * @return
	 */
	public int getProgressSerializationItemCount();

	/**
	 * Get the number of steps of a channel deserialization process. 
	 * @return
	 */
	public int getProgressDeserializationItemCount();
}
